<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        img {
            width: 150px;
            height: 130px;
        }

        .box {
            /* 水平居中 */
            text-align: center;
            padding-top: 30px;
            padding-bottom: 30px;
            background-color: rgba(97, 131, 174, 0.6);
        }

        body {
            background-image: url(../img/1.jpg);
        }
    </style>
</head>


<body>
    <div class="box"></div>
    <img src="../img/1.jpg" />
    <img src="../img/2.jpg" />
    <img src="../img/3.jpg" />
    <img src="../img/4.jpg" />
    <img src="../img/5.jpg" />
    </div>
    <script>
        window.onload = function () {
            var images = document.getElementsByTagName('img');
            for (var i = 0; i < images.length; i++) {
                images[i].onclick = function () {
                    var imgSrc = this.src;
                    document.body.style.backgroundImage = 'url(' + imgSrc + ')';
                }
            }

        }
    </script>
</body>

</html>